﻿<!DOCTYPE html>
<html lang="en">

<head>
    <title>强制指定流解码器</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <style>
        #example {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }
    </style>

</head>

<body>
    <select id="switch">
        <option value="1">使用Hls</option>
        <option value="2">使用VndAppleMpegUrl</option>
        <option value="3">使用UseXmpegUrl</option>
    </select>
    <div id="example"></div>
    <script src="../build/three.js"></script>
    <script src="https://cdn.bootcss.com/flv.js/1.5.0/flv.min.js"></script>
    <script src="../build/mxreality.js"></script>
    <script>
        window.onload = function () {
            init();
        }
        //var vr=new VR(scene,renderer,container);
        function init() {
            var scene, renderer;
            var container;
            //renderer = new THREE.WebGLRenderer();
            AVR.debug = true;
            if (!AVR.Broswer.isIE() && AVR.Broswer.webglAvailable()) {
                renderer = new THREE.WebGLRenderer();
            } else {
                renderer = new THREE.CanvasRenderer();
            }
            renderer.setPixelRatio(window.devicePixelRatio);
            container = document.getElementById('example');
            container.appendChild(renderer.domElement);

            scene = new THREE.Scene();

            // fov 选项可调整初始视频远近
            var vr = new VR(scene, renderer, container, {
                "fov": 50
            });

            document.getElementById('switch').addEventListener('change', function (e) {
                var type = this.value;
                vr.liveSettings.forceUseHls = false,
                    vr.liveSettings.forceUseVndAppleMpegUrl = false;
                vr.liveSettings.forceUseXmpegUrl = false;

                // 强制指定
                if (type == 1) {
                    vr.liveSettings.forceUseHls = true;
                }
                if (type == 2) {
                    vr.liveSettings.forceUseVndAppleMpegUrl = true;
                }
                if (type == 3) {
                    vr.liveSettings.forceUseXmpegUrl = true;
                }

                vr.playPanorama('http://localhost:8000/live/test.flv', vr.resType.flvVideo);
            })

            //vr.playText="<img src='img/play90.png' width='40' height='40'/>";
            vr.vrbox.radius = 600;
            if (AVR.isCrossScreen()) {
                // 调整vr视窗偏移量
                vr.effect.separation = 1.2;
            }
            vr.loadProgressManager.onLoad = function () {
                vr.video.setAttribute("loop", "loop");
                vr.video.crossOrigin = "Anonymous";
            }
            //AVR.useGyroscope=false;
            vr.init(function () {

            });

            vr.playPanorama('http://localhost:8000/live/test.flv', vr.resType.flvVideo);




            vr.video.onended = function () {}

        }
    </script>
</body>

</html>